package day07;
//计算总分平均分
//6名评委打分,要求分数在0-100之间
//去掉最高分 去掉最低分 后4个评委的平均分

import java.security.PublicKey;
import java.util.Arrays;
import java.util.Scanner;

public class CalTotalAvg {
    public static void main(String[] args) {
        double [] enterDate=enterDate();
        double toalScore=toalScore(enterDate);
        double averageScore=averageScore(toalScore,enterDate);


        System.out.println("平均分为:"+averageScore);
        System.out.println("总分为:"+toalScore);





        }

        public  static double []  enterDate() {
            double[] scores = new double[6];
            Scanner scanner = new Scanner(System.in);
            for (int i = 0; i < scores.length; i++) {
                System.out.println("请输入第" + (i + 1) + "个评委的分数");
                scores[i] = scanner.nextDouble();

            }
            return scores;
        }

        public static double toalScore(double [] scores){
            Arrays.sort(scores);
            double toalScore=0.0;
            scores[0]=scores[scores.length-1];
            Arrays.sort(scores);
            scores=Arrays.copyOf(scores,scores.length-2);

            for (int i = 0; i < scores.length; i++) {
                 toalScore+=scores[i];
            }
            return toalScore;

        }

        public static double averageScore(double toalScore,double [] scores){

        double averageScore=toalScore/(scores.length-2);
        return averageScore;
        }

















}
